Surprisingly to me, I could not find any documentation on Shopify on the algorithm behind the 'Best Selling' sort order on collection pages. So I reached out to customer support about it. Here's their explanation:
Best Selling collection sorting is done by adding up the line items that contain a product_id. So for an order with multiple variants, each variant is counted as one instance.
Product A will appear higher in Best Selling sorting because it appears on more orders. The sales of all variants per product's line item appearances are totaled to calculate best selling. This information will update in real-time.
The timeframe for the calculation is over the lifetime of the store.
In other words, best selling is just a stack ranking of product sales over the life of the store. So there's no recency or seasonality to the algorithm.
Now you know!