Should I be renting or buying?

My husband and I are planning on living somewhere for 2 years (renting) and then moving to a different state and then buying a house. However does it make sense to rent for that long? Our real estate agent is saying we should buy a house then move and buy another house instead of investing 40k in someone else’s for those 2 years. But what do y’all think?

My husband and I are comfortable but also don’t have a lot of money. Does it make sense to rent for those two years or should we look to buy?

I have no experience in these things so just looking for advice.

Should I be renting or buying?
Post Opinion