In America, the problem comes when the gain and the loss come in different years. If you make a big gain in 2024, but didn't pay taxes on that gain, then lose the money in 2025, they will come after you for failing to pay taxes in 2024 even though you no longer have the money in 2025. The lesson is to pay your taxes.
A bank will be happy to lend you the money to cover the spread since you have the collateral of a large tax refund in the future. It'll cost you a little bit of interest but it's generally not the catastrophe that people make it out to be.
Maybe if you are an ultra high net worth individual. I don’t see your avg Joe walking into their neighborhood Chase bank asking for a $500k loan using their potential tax refund as collateral is going to get it. That seems like an esoteric financial product.
Tax refund loans are offered in conjunction with the tax filing service like TurboTax or H&R Block because they already know what your refund amount is going to be and it’s relatively risk free (small refund amounts) and easy to automate. They are similar to pay day loans.
Crypto bro showing up with $1m gains and losses from crypto transactions and asking for a refund loan at their neighborhood bank is probably not going to go anywhere (it’s too large a risk because it’s not just a few thousand dollars but at the same time it’s too small an amount for them to do custom due diligence to underwrite a loan).
Anyway you can’t erase gains in year 1 with losses in year 2 at least in the USA (you can only offset $3k/yr max in year 2 if you don’t have any other gains).