If I put a school first choice but live further away than someone who puts it second, who gets the place
Assuming the school uses distance as the tie breaker and you are both in the same admissions category, the person living closer gets the place even though they named it as their second choice.
As Paddington68 says, the order you put your preferences matters. If you qualify for offers from two or more schools you will only be offered the place at your highest preference. It is therefore important that you put your preferences in your genuine order of preference. Do not try to game the system. At best it will make no difference. At worst you could lose out on a place you really wanted.