That is basically just what Ajax does, to stay simple, the ajax call gets the content of the file. So if your php file is in a server that is able to run php, the code will be executed. But only the content that you "display" on the page will be retreived by the ajax call, example:
file1.php -> nothing is diplayed, code will run and variables will take the values, but ajax call will return an empty string:
<?php $x=1; $y=$x+1; /* -> y: 2 */ ?>
file2.php -> an echo is made, code will run and variables will take the values, the ajax call will return a string with only what was diplayed: 2
<?php $x=1; $y=$x+1; echo $y; ?>
file3.php -> all text outside of php will be returned by the ajax call too: y = 2
y = <?php $x=1; $y=$x+1; echo $y; ?>
Usually you will use data formatting if you want to pass data, like JSON.
It means that Ajax is not made to redirect the page, but execute an outside code or retreive data. At least you could retreive the new URL to redirect, then redirect in JS, if this is what you want, but not redirect just from the PHP code you call. It is a different page.