A seller in a market with limited active listings can often negotiate a longer possession date as part of the sale itself, which buys time to find the next place without carrying two mortgages at once.
Buying first only makes sense with a strong pre-approval, a real cushion for carrying two properties briefly, and a lawyer lined up to coordinate both closings on tight notice if the numbers work out that way.
Either order can work, but it should be chosen deliberately based on your actual numbers, not on which listing you happened to see first. Get your hand-reviewed valuation from Joel Dyck.