Antennas with higher gain and efficiency deliver superior performance across a wide frequency range. Achieving these characteristics at high frequencies while keeping a compact size necessitates sophisticated design approaches. This research presents a substrate-integrated waveguide (SIW) cavity-backed slotted patch antenna (SPA) tailored for the 28 GHz and 34 GHz frequency bands. Additionally, a linear tapered slot antenna is designed with a compact profile of 27.5 mm × 7.5 mm × 0.254 mm. The SIWs are implemented using vias on the outer profile of the antenna, and circular and rectangular slots are etched on the radiating surface. The goal of optimizing the antenna geometry is to enhance return loss within the desired frequency bandwidth, which means the Genetic Algorithm (GA) will determine the optimal antenna shape to achieve lower return loss than the original design within this bandwidth. The antenna exhibits dual resonance at 28 GHz and 38 GHz in the millimeter-wave range, providing an impedance bandwidth of 211 MHz (27.72 GHz to 27.94 GHz) at 28 GHz and 127 MHz (37.88 GHz to 37.98 GHz) centered at 38 GHz. The proposed antenna demonstrates gains of 8.04 dBi and 9.72 dBi at these operating bands. A prototype of the antenna is fabricated on RT/duroid 5880 and its characteristics are measured. The overall VSWR of the antenna ranges from 1 to 2, with a radiation efficiency of 94%. The proposed antenna achieves dual-band performance with increased directivity and stable gain, exhibiting enhanced electric field distribution, radiation patterns, and reflection coefficient (S11), all of which contribute to a comprehensive understanding of the antenna's performance. This study compares the designed antenna's performance to that of the fabricated prototype. The proposed antenna is ideal for 5G applications due to its small size, broad spectral coverage, and excellent gain..