How do I not get these on my legs?

It’s like every time I shave I get these bumps and idk how to avoid them, does Anyone know what they are and/or how to avoid them