But how does a VPN prevent those things?
Alone, it's not the most effective, like the lock on your front door handle. Like the lock on your front door handle, it only keeps out the honest criminals.
Your Advertising profile, in the US the most common one is your Credit/Consumer Profile, tracks your ip address, browsing habits (through super cookies/app sniffing), and your overall fingerprint on the internet. This means Google really does know you visited facebook 12857192 times in the last year, it knows you searched your old crush's name, and it knows the size of the sex toy you most likely are to buy based on how many seconds you spent on sex-toys.jesus thanks to google analytics plugins tracking your ip address back to the same one you used on google, the same one you used on facebook, etc.
Giving them a common, easily searchable, easily provable (without a warrant) data point to tie all their other data points is literally doing their work for them, and is making them wealthier than all their other business ventures combined. If you use a vpn and regularly change your ip address, fingerprinting is harder. If you use a slightly hardened browser and/or mobile OS, fingerprinting is harder. The less information they have on you, the less information they can sell to the government without a warrant.
This is like if you had a magic button to change the license plate on your car. Flock would be worthless, for the most part. Yes Flock collects a lot of other data, but if you cannot tie that data confidently to a single user, it becomes useless and worthless.
--
Secondly, many VPNs do not keep logs, many do not run their software on persistent media whatsoever, preventing all possible warrant scenarios, even if they were in a country that was able to send them a warrant.
This prevents one data point in government tracking, the easiest one to explain to a judge. The easiest one to explain to a jury. If you make a comment on twitter that ICE doesn't like, they will subpoena twitter for your ip, subpoena your ISP for your personal information, and then pay you a visit.
Guess what they have to do if you have a VPN? They have to subpoena twitter for your email/phone address/device ID/IMEI/etc, then, with varying levels of difficulty, all of which can be avoided using simple opsec tactics, subpoena all of those related companies, and then hope you used personal information like your personal IP when interacting with any of those services, and then pay you a visit if, with all this extra work ALL OF WHICH HAS A LAYER OF PLAUSIBLE DENIABILITY THE MORE LAYERS YOU HAVE, convince a judge to let them pay you a visit.
Given how quickly it is becoming illegal to be trans in the united states, gay people aren't far behind, and honestly anyone brown should already be on a vpn and have anonymized online accounts when posting, you should be working on reducing your fingerprint-ability via every means. Given you can get a vpn for 5 euros a month paid through monero, there's no real excuse not to have that easy extra layer.