Alter table inner workings

There’s lots of info on the Internet about what the ALTER TABLE instruction does, but how does ALTER TABLE actually work? Which part(s) of the MySQL source code can describe what happens?

There is no short answer to this question. I’d suggest to start reading from:
https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html
https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-space-requirements.html