It's done several ways.
The first technique (for modern films) is CGI. I don't really think these need much explanation, so: onto the next one! In the past this effect was created through firing bursts of air into water.
Nowadays it’s mostly done with CGI. In the past, it was done with non-CGI camera tricks such as firing bursts of air or using underwater projectiles (spears, arrows, etc.). You can’t do it with real bullets because it doesn’t work, at least not like it shows in the movies.
- In movies, what do they shoot into water to simulate bullets? - Quora
Another interesting technique I found out about is the technique that Steven Spielberg used in Saving Private Ryan.
The go-to example of deadly bullets streaming through water, in a movie, is of course, Saving Private Ryan.
Spielberg certainly has more flexibility than most with his budget. He actually attempted the effect shooting pellets (not bullets) being fired through water into blood bags. Pellets are normally made out of lead.

In the still frame, it looks like they did some editing to make the pellet look like a bullet. They probably used pellets as a safer, lower power alternative to bullets, perhaps not wanting to risk damage to their water tank.
- In movies, what do they shoot into water to simulate bullets? - Quora
So, there are several options when creating a film to produce the effect of bullets going through water.