You certainly don’t need to. I would even argue going to university is not where you go to learn how to code. At least not through a CS degree anyway.
I have a lot of respect for people with CS degrees and greatly appreciate the value of studying computer science, but they don’t teach you how to code. A CS degree has a very broad curriculum and programming tends to be a tiny aspect of it. Any coding you do is not even close to industry standards at all.
There are a lot of college/uni programs out there that focus more specifically on programming which will teach you quite a bit more than what you’d learn studying CS. The issue with learning how to code in college is that even schools that put a lot of effort in communicating with local companies in the industry to keep their content relevant, still won’t teach you everything you need to know to be “job ready”.
I’ve seen a lot of decent college courses not even mention Git for example. Students have to learn about that by being proactive and joining local meetups and finding other resources to learn from in tandem to their college program.
In my experience few people who attend university or college are able to just jump into a job working as a programmer without doing quite a bit of self-study outside their schooling. Although if your school offers co-op or internship placements it’s definitely possible!
You can definitely learn how to code and probably pick up industry standards much faster on your own by taking courses online. If you go the self-taught route, getting that first job can be really tough.
If you know you want to be a programmer, and you can afford to go to school for it I think the safest path is finding a college program that specializes in the area of the tech industry you want to work in (such as web development for example) and make sure there’s a guaranteed co-op or internship placement.
However, all of the above paths are totally valid and will work out in the end.