There is a small split for how you would freelancing vs. consulting via agencies in my experience.
For consulting, you will usually only be brought on if you have a special skill set that the agency themselves can't fill out, and often only if their client specially requests those services. So consulting work via agencies is much rarer in my experience.
For freelancing, as long as the agency is doing well there is almost always something to do, and ~20% of their tech teams consist of freelancers, so it's not really "surplus work" but more their part of their normal mode of operation.
Of course, all of this are just anecdotal data, and may vary widely from region to region.
A cold email better be great to work. A better bet is to go to meetups and local conferences for like Wordpress or SEO or digital marketing. You’re likely to meet some agency folks or people who contract with agencies. Chat them up, offer to buy them lunch, stay in contact.
Or, just look up agencies who are hiring for developers. Contact them and offer your contracting services.
A good portfolio is key. Strong client references are even better but it takes time to build those.
You can also do thought leadership type stuff like blog about topics, or participate in regional online communities.
I’m familiar with agencies because I have hired and worked with a lot of them recently.
For example: One of our oldest business associates, who has passed over a lot of work over the years, we met volunteering for the local seafood festival.