I'll see if I can explain it clearly and accurately.
It has to do with how the server, the php interpreter, and the browser, in turn, handle a file. When a file is included from php, the server parses that file as html until an opening php tag is encountered. Since the server is still in control, the php is interpreted and the output is then sent as html. The browser, which has the job of interpreting html, does so when it receives the output.
Even a plain text file is considered as normal html text by the server when included. Also, a browser will display anything between "<textarea>" and "</textarea>" exactly as it is received, i.e. without interpreting it. That's why your script displayed the text as you wanted it displayed.
By reading the .php file into a string and sending the string instead of php output to the browser we are able to have the php script itself displayed.
Examples:
<textarea rows="10" cols="70">
<?php
echo 2 + 2;
?>
</textarea>
displays "4".
<textarea rows="10" cols="70">
<?php
$php_str = '2 + 2';
echo $php_str;
?>
</textarea>
displays "2 + 2".
<textarea rows="10" cols="70">
<b>Textarea display</b>
</textarea>
displays "<b>Textarea display</b>".
Sorry for the muddled explanation. Maybe someone else can clarify or correct some points.