Vagina closed for business?!

So I was enjoying my time with a guy (my 2nd time ever), but it seemed to be more painful than the first time although we took our time and did foreplay this time around. It almost felt like my vagina closed shut and after many attemps and different positions it still took us a while until we could have have sex. Why did that happen? And does this happen sometimes even with having had sex for a while? P.S. I was in the mood and enjoying it all and was not stressing or nervous either. Please help!!!