Generally, you have to apply to the high school within your borough, unless you apply to the likes of Stuyvesant, Bronx Science, or Performing Arts but then you have to take the admission test or pass the audition.
High schools have an order of admission criteria. Applicants zoned for a particular high school get admitted, no matter what, then, if there are any seats left, the students from the borough. If the school is in high demand, many who live in the borough won't get in. Schools where there is little demand may accept students from other borough, but why would you want to apply to those schools in the first place?
For students from other boroughs they do take your address and where the school is located into account, so if you live in Riverdale, for example, and apply to Tottenville, you won't get in.
Read the High School Guide; it lists the admission criteria (e.g. grade point average, standardized test scores, attendance, residence) for each high school. Talk with your Guidance Councilor. Hurry up, those applications are due just about now.
Went through the HS admission process for my oldest son last year; will be doing it again for my youngest next year.