AT&T Inc. on Sunday agreed to buy DirecTV for $48.5 billion, or $95 per share, a move that gives telecommunications company a larger base of video subscribers and increases its ability to compete against Comcast and Time Warner Cable, which agreed to a merger in February.