The Nasdaq and the S&P 500 had their worst day since June as investors worried about spending on A.I.