how to avoid a UTI?!?

I literally feel so stupid right now. I was having sex with my boyfriend two nights ago, and we don't use condoms. We were both (legally) under the influence and we tried anal. We've done it before, but it hurt so bad this time and he could definitely tell, so after a minute or so he pulled out and went back into my vagina without washing up or anything. In the moment I didn't even think about it but now I'm scared I might get a UTI or a yeast infection or something. I haven't felt anything unusual yet, but is there anyway to prevent it from happening?