If you are German then no one should have told you there's no possibility of freelancing, but it might make more sense to first take on enough Swiss customers freelancing from Germany, or as a commuter to Basel, etc. I would just recommend being conservative about maintaining a reasonable/stable salary sourced from Switzerland when renewing a residence permit.
If you really mean contractor gigs from abroad, everyone I met doing that actually works permanently for a placement agency, and most of them are not very nice. IMO it is just as easy (or hard) to find a job directly and better.
I tried directly and also over an agency, but in both cases the requirement was to hire me, with the previous mentioned "limitation". Since I had no clear source of information, I gave them credit and didn't pursue the matter. Even if the money was really really good ( 10k+ euro monthly ).
They told me, there is no such thing a service contract between an individual and a company. I must be either hired or I need to have my own company.
I am not inventing this, simply repeating what the companies said, and they really meant it.
You can be a sole proprietor for basically nothing. There's also two forms of limited companies requiring 20K/100K of capital. The 100 is actually 50K because you only have to pay up half of it upfront.
I found quite often when the Swiss explain something, they explain it with a degree of confidence that is not merited by the actual facts. They cut a few corners here and there to make it easy to explain.
That's absolutely wrong, you've been lied to. Which part of Switzerland was it?