I have never understood apostrophes so my English teacher told me if in doubt leave them out
It's pretty easy!
1. If you're missing a letter out. For example "you're" is short for "you are". I missed a letter (and a space) out so I put in an apostrophe. Similarly "it's" is short for "it is". I missed some stuff out, so I put in an apostrophe.
2. Just like the above, but for possession. Before apostrophes were invented I would have to write something like "the post of TJ was thought-provoking". No-one has said anything like that for 300 years – instead we say "TJ's post…".
Just like (1), I missed something out, so I put in an apostrophe.
3. Don't be confused by "The dog has eaten its food". There's no apostrophe here because "its" is just the same as "his" or "hers", only for things. You wouldn't write "He has eaten hi's food".
4. There's some confusing stuff about apostrophes with plurals. The apostrophe usually goes on the end, but if in doubt just use the collective noun instead! "The flock's needs were met by the shepherd."