it's not a problem that they run simultaneously (which I'm not sure they do in this case).
If you have a website that has a form that inputs some information into a database each time it's filled out, if two people fill out the form at exactly the same time does this break the website?
EDIT: if I've misunderstood this and you actually meant that query 2 is using the query stored in the first $sql , it doesn't because you've redefined it for the second query, and re defined it again for query 3 / 4 / 5 etc. IE:
//query 1
$sql = 'SELECT * FROM `test`';
//rest of query
//query 2
$sql = 'SELECT count(*) FROM `test2`;
//$sql no longer = 'SELECT * FROM test
' as you've just redefined it as 'SELECT count(*) FROM test2
;