The S&P 500 and the Nasdaq Composite hit intraday record highs before retreating as investors weighed the latest developments in the Middle East.