The answer by mhoran_psprep gives a very good example, but I'll explain more about the rationale of the concept.
Similarly to the US wash sale rules, in Canada the law prohibits tax loss harvesting as the sole rationale for the transaction. In the US this is because the short term capital loss is more valuable than long term capital loss, and both in the US and Canada this because capital loss offsets capital gain for tax purposes and tax loss harvesting allows deferring taxes. The tax agencies want to avoid this.
In some other countries there are no such rules, and in fact taxpayers are allowed to do tax loss harvesting even without selling the assets, just by resetting the cost basis. The existence of wash sale rules is a matter of public policy.
As the other answer explains, the rules are written in a way that removes the ordering of the events from the equation. It doesn't matter in what order you sold the loss or repurchased the asset, as long as it is done in a reasonable proximity to each other (within 30 days either direction), you're on the hook. The assumption is that it is much harder to anticipate market moves for the period of multiple weeks than it is for a period of days or hours (or seconds), this imposing such a period removes the incentive of tax loss harvesting being the only rationale for the transaction.