Can I put contingencies in place, so I don’t have two mortgages?

Yes, and it is a good idea to do this because it protects you from having to close on your new house until you have sold your current home. It also protects your earnest money deposit, in the event you are not able to close on your new home because your current home has not sold in time.