The performance of modern wireless communication systems is highly dependent on the adoption of multiple antennas and the associated signal processing. In 5G and 6G networks, beamforming and beam management become challenging tasks due to aspects such as user mobility, increased number of antennas, and the adoption of higher frequencies. Artificial intelligence, and more specifically, machine learning, are efficient tools to reduce the complexity involved in generating beams and the overhead associated with beam management without sacrificing system performance. Therefore, AI-aided beamforming and beam management have received a lot of attention recently. This article presents a complete survey on this topic, emphasizing open problems and promising directions. The discussion includes architectural and signal processing aspects of modern beamforming and beam management. The article presents communication problems and respective solutions using centralized/decentralized, supervised/unsupervised, semi-supervised, active, federated, and reinforcement learning.