How can Blockchain be safe from 51% and quantum attacks?

51% is a specific attack on the consensus mechanism. So there, don’t use Proof of Work, use something that isn’t “majority wins”

Similarly, QC is a (potential) threat to asymmetric cryptography (EC in the case of bitcoin) used for wallet addresses; the solution is to move to post quantum algos for wallet addresses. note that blockchain itself doesn’t use wallet addresses (that’s payload, not structure) so its pretty much just cryptocurrencies there.