WASHINGTON—President Biden, whose support for Israel dates back a half-century, faces a foreign-policy conundrum following Hamas’s devastating attacks: how to support the closest U.S. ally in the Middle East without pulling America into a dangerous regional conflict.