TOKYO—As the U.S. presses tight sanctions on Moscow, it might seem quixotic for one of America’s staunchest allies to seek closer ties with Russian President Vladimir Putin. But that is the balancing act Japanese Prime Minister Shinzo Abe is trying to pull off.