Disclaimer: I don't know how etherscan does this and I don't know any correct/standard way to decode contract transactions/functions. I am also in search of the right answer here. But here's my insight.
There is the option on etherscan for contract developers to upload and verify the contract code, which in turn discloses the details of the contract such as the function signatures and event names which then presumably can be utilised by etherscan to decode the transaction details.
For example the seaport contract has its contract source code verified on etherscan: https://etherscan.io/address/0x00000000006c3852cbef3e08e8df289169ede581#code
With this said, this may not be the (only) way etherscan handles contract transactions. There are a lot of contracts without the source code, and etherscan decodes the details just fine.
One way to decode contract transactions without the source code is to compare the event logs with known events. For example, standard ERC20 transfers emit events with the same topic which is a hash of the event name. For example in this Coinbase transaction that makes multiple token transfers: https://etherscan.io/tx/0x022f2d974fc2ae9652edb846c14474be6baca76dfe2c6cb5fd1af425c7c976f7, event logs are all the same ERC20 transfer topic, despite they're from an unknown contract.
Again, there are contract transactions without clear explanatory data, and etherscan processes them just fine. Regarding internal transactions, there is another answer here that suggests etherscan run modified evm nodes themselves to record the transfers.