What happens behind the scene when the PID block in the Matlab Simulink is tuning and linearising the plant, designing the controller and so on ?
It linearizes the model around an operating point (either default, or one you specified), and then uses a proprietary algorithm for tuning the PID gains. See http://www.mathworks.co.uk/help/slcontrol/ug/introduction-to-automatic-pid-tuning.html for more details.