Another very helpful thing to break into contracting is building a reputation for great work as well as a large professional network. When former coworkers become managers and need help they’ll know they can count on you. And may be willing to bring you in as a non-FTE.
Lastly, I’d say work to be a desirable candidate in general. I had a multi-year engagement that came out of an interview after which the company enthusiastically wanted to hire me. I turned them down, but said I could contract 20 hours a week. They accepted.
A surprising number of smart developers aren't actually all that good at building software that people can use next week. They get stuck optimizing for every conceivable edge case and refactoring to make sure everything is abstracted out so their CS prof would approve, and go down rabbit holes of tweaking interesting bits of technology. But they never get around to building the thing so that the people who need it can use it to do their job.
So after building enough things at enough places for enough people, I started picking up a reputation as a guy who could build things, so when those people started talking to other people at other places who needed things built, my name would naturally come up.
Eventually, I put together a collection of artifacts in the form of working SaaS products that I could point to as examples of things I had built from bottom to top, to skip the need to have other people bring my name up. And one of those SaaS products is subtly engineered to spawn customers with needs that are nearly, but not perfectly, met by the product itself. Thus making them natural candidates for short consulting gigs to build them a version of the thing that better suits their needs.
https://softwaredoug.com/blog/2020/12/22/hack-your-career-wi...
TL; DR I became attracted to a particular challenging problem and just blogged and wrote about it a ton. I jumped on professional opportunities well like authoring some open source that fit in strategically or writing a book. You need not go this deep, but at a minimum you can work on identifying the people in the niche you want to focus on, network with them, find other consulting vendors, let them know you want work (they might sub to you, etc).
Do use common sense, don't pick too-risky projects, and make sure you get better and better at estimating (this is a huge one!).
Learn how to make drivers and you can write drivers for a company with a new product.