Recently Firo, former Zcoin had a 51% attack and it was possible to change/tamper data of 306 blocks(or so). What exactly is that? Is it like the guy who had control of 51% of the network had overwritten the block? How does anyone get benefitted from such an attack? What's the step to prevent such attack?
51% attack is done by mining on top of some earlier block, which means that all transaction after that block become unconfirmed, and another transaction that spends the same inputs could be confirmed instead. In worst case, the coins that you have received in a block that was reversed will never appear in your wallet again. As its name suggests, 51% attack is done by having more than 51% of network hashrate, because it allows you to create a longer chain, or chain with more combined hashpower, which forces nodes to switch to it as per protocol rules.
In this case, the hackers have profited by sending coins to exchanges, selling them, withdrawing the money, and then reversing the deposit transaction, so they can sell these coins again. This is known as double spending.
To prevent it, you need to adjust the required confirmation time to network's hashpower. With Bitcoin 1-3 confirmations is enough for most purposes, with smaller altcoins you need to wait thousands or even tens of thousands of confirmations to be truly safe. IMO exchanges will realize that this is not worth the risk and will start delisting shitcoins with low hashpower in the future.