United Airlines and the union representing 21,000 mechanics and ground workers reached a tentative contract agreement, averting a nationwide strike that threatened to shut down the giant carrier, a union official said. The agreement was reached in Washington by negotiators for United and the International Assn. of Machinists just hours before the expiration of a 30-day cooling-off period barring a walkout. Richard Delaney, president of Local 1487 in Chicago, said that he was notified of the agreement but had no details of the proposed contract. He had said earlier that employees were prepared to walk picket lines at 12:01 a.m. today, when the no-strike period expired.