Just because the law forces them to
make the money available doesn't prevent them from putting a big warning on the associated transaction.
Clearly, the bank knows how cheques work and how they can bounce 6 months down the line. They should make it clear to the user with a warning explaining "we are required to make this money available to you by law now, but this money can be taken back at anytime if the cheque ends up being fraudulent, and this can happen for up to 6 months down the line".
The bank also knows (doing otherwise would make me doubt their competence to operate a bank) that this is a common scam and should similarly warn their customers about it. They also know (and have the data) to prove that a lot of people fall victim to this scam suggesting that there is a lack of knowledge in the majority of people when it comes to how cheques work and how they can bounce down the line after the money has already "cleared".
Finally, when it comes to the law, the law was most likely drafted at a time where 1) there were no easier ways to transfer money instantly while making sure it's actually legitimate, so it was a necessary trade-off and 2) there were similarly no easy ways to irreversibly transfer money out of the country in an untraceable fashion, so that the majority of occurrences of such scams would also give better chance to law enforcement to actually trace the funds and make the victim whole, so the fact that someone could temporarily end up out of pocket was also not a big deal.
Nowadays that particular law is clearly inadequate and is doing more harm than good, but laws take time to change (and no doubts there are vested interests at play that would want the system to remain as-is) and there's nothing preventing the banks doing their own part to "patch" the bug until a proper fix can be installed (by deprecating the whole cheque system altogether).