This is a slimmed down version of "The Four Corners Murder" which posits that a person who is standing on the marker of the Four Corners (a singluar point where the boarders of Arizona, Colorodo, New Mexico, and Utah meet and is the only place where four states meet in such a manner in the U.S.) and is shot.
Typically, the scenario posits which state can prosecute the murder (the state in which the murder shot the gun or the state where the victim fell) or if it's a legal murder as firing a gun is not a murder and the victim was not in the jurisdiction of the accused.
In actuality both in your scenario and the other all involved states will be able to prosecute the accused for all crimes committed while straddling the boarder. Thus, in the four corners, the murder is prosecutable by all four states one time each (Double Jeopardy applies to a jurisdiction. If the same crime is cross jurisdiction, each jurisidiction can prosecute and find guilt no matter how many other jurisdiction already heard the case.).
BUT WAIT, THERE'S MORE:
The murderer can be prosecuted an additional three times: The four corners are also part of the boundry for the Sovereign Dependent Native American Nations of the Navajo Nation and the Southern Ute Indian Reservation, both of which have their own legal systems independent of the States they reside in that can prosecute just the same as the states. Finally, since the crime also "crosses" state lines, the Federal Government has jurisdiction to prosecute.
In the likely scenario, the state, or tribal Law Enforcement that makes the arrest will likely try the case first, while the remaining five legal entities will file for extradition to stand trial in their own states/tribes if they are not satisfied with the first's justice (or they are satisfied, but they want to punish the accused as well). The federal government will go last and as a policy rule it will decide to drop charges pending the state's outcome when the charges are similar regardless of verdict. They can prosecute for non-state level crimes.
As a general rule, if you are straddling the border, the state that makes the arrest will be asked to extradite to stand trial for charges as well. So long as a part of you is legally in one state, it does not matter that the part breaking the law was in the other state, they can prosecute you for committing the action in their state as if all of you was over the line on their side.