Avoiding blackheads is hard! They are from a combination of genes, diet and makeup in my opinion. There is nothing you can do about genes, which affect the size of your pores (where blackheads can build up). But you can make sure that you always wash your makeup off, exfoliate your face 3-4 times a week, and wash it morning and night. A diet rich in foods which are less processed (less packaged food) could also help with black heads, trying to eat foods which are fresher (wholegrains, vegetables, fruit) and less oily (less takeaway or greasy food). And of course making sure you drink a good amount of water to keep hydrated (1 to 2 liters a day)
The best way to get rid of ingrown hairs is with out a doubt exfoliating. I would get a loafer and softly exfoliate in the shower 3-4 times a week (not too hard as this will cause trauma to the skin and possibly worsen them). This will take of a top layer of skin off and hopefully allow the hairs to come through. Don’t keep the loafer in the shower though as it will grow bacteria (gross!) take it out, rinse it and let it dry each time you use it.
-Another thing I think causes them is clothing or underwear that consistently rubs on the area of skin where they appear. Not a lot you can do about this, but be conscious of it and avoid tight clothing and underwear while you sleep.