Once an Ethereum smart contract is deployed, its code cannot be changed. This is achieved through the EVM (Ethereum Virtual Machine) and the nature of blockchain itself.

Why?

Bad things

If a contract is deployed with a vulnerability, you cannot directly fix the contract. The only option would be to deploy a new version, which might not be practical if the contract holds valuable assets or has been in use for a long time.

Ref - https://nftnow.com/features/akutars-exploit-34-million-locked-in-smart-contract/

https://x.com/0xInuarashi/status/1517674505975394304