Your question has elements of long range business planning mixed with "survival" activities. I assume that the freelancing is to get started and your long range plan is to have products.
For example, say our expertise is ASP, but we can't wait for ASP projects to become available, so we take a JSP project instead, which we are not experienced with.
How did you succeed and sustain freelancer jobs?
About freelancing and how I stayed in business doing software contracting for about 18 years:
So you say you have had problems accepting work that you aren't qualified to perform.
Almost all clients hire contractors because they are expert at some skill that the client doesn't have in-house. You simply must not accept projects that require knowledge and skills that you do not have. Unless: you are prepared to invest whatever effort is necessary to overcome your learning curve, and to do so at your expense and not the client's expense.
Almost all freelancers make a steady living by being really good at one particular thing such as a language skill set applied in a particular domain.
For example, I made a living for years developing Windows client applications and actual products using C++ and Delphi.
To freelance successfully and consistently you have to be kind of a "one stop shop" for a particular kind of solution. In general, most freelancers have better luck when they specialize somehow. This would be the absolute remedy for accepting projects that don't fit your skills.
Our next target is to find local customers in need of a software solution and develop what they need. Is this a good idea?
If you are trying to build a business, it's only a good idea if you can keep the rights to the code that you develop. Ideally, you build a base of code assets from past freelance projects that you can re-use. In other words, avoid work-for-hire arrangements and assigning all rights to the client. In that instance it becomes temporary labor.
Also, it's only a good idea if you can actually sell the ability to create those solutions. Again, you need to specialize in particular types of problems.
Or should we develop a generic product (say a CRM) and present it to customers and deliver it on demand (a customized one)?
A few things:
Good luck presenting a CRM or any other plain old tool to business customers and having them understand what they just saw. Besides, a CRM may not fit the client's needs at all.
Demos DO work but only when the demo shows things that the prospect can relate to. You would have no luck showing a CRM to an end user. Show a prospect something that appears to solve one of their current problems and perhaps you can win them as a possible client.
Find unique business problems that clients have and solve them. And define a niche to go after, like a particular kind of business (example: insurance agencies; or restaurants.)
Just one warning: line of business applications are an incredibly saturated market simply because so many developers have been developing solutions for decades. However, there may be opportunities in creating modernized versions of existing applications, such as cloud or server based versions of workstation applications.