Does the ‘init’ hook works for all sites in multisite?

If your code is in a theme’s functions.php, it’ll only run on sites where that theme is active. You can ensure that it’s active on all your sites by putting that code snippet into a plugin that’s active on every site (ie, Network Activated). Alternately, you can use a Must-Use plugin to ensure that it runs on every site in your Multisite network.