I have no doubt luck was involved. I hit the market at a good time and gained traction quickly. I have done zero marketing and customers come in through word of mouth and via search engines. Surely there was luck in there.
As for choosing the idea-- that was more systematic. I chose a service that solved a real pain point for many companies in a specific industry. I chose it because it because:
1. There were many competitors (10+). That meant someone was making money, and more importantly, someone was spending money.
2. The industry/customers had a very clear channel for early word of mouth/traction (ie, it was easy to reach the customers and say "hey look at this solution for X").
3. A cottage industry exists around the industry. There are many "influencers" and training seminars, conferences, etc. Once my service gained some traction it was easy to stick around because people kept talking about it at conferences. I also gave access to these "influencers" for free.
I'd say stick to B2B, and look for 1-3 from above.. those are ideal for a solo-SaaS product.