Records of the Three Kingdoms
Zhuge Liang’s biography says that in 225 the Nanzhong commanderies rebelled, he led the army south, and by autumn the rising was settled. The main text does not name Meng Huo and does not describe seven captures and seven releases.
Pei Songzhi quotes the Han Jin chunqiu: in Nanzhong Zhuge Liang captured Meng Huo and released him, and did so seven times. Meng Huo said that Zhuge Liang’s awe was heaven’s, and the southerners would not rebel again. The same commentary quotes other accounts, so the campaign was already told in more than one way. The Huayang guo zhi also mentions Meng Huo. What is firm is that Zhuge Liang settled the Nanzhong revolt in 225. The detail of the seven captures is not in Chen Shou’s main text.
Romance of the Three Kingdoms
The novel makes the southern campaign seven different methods of war: the rattan armor burned, the mute spring, the valley of coiled snakes, Meng Huo’s wife Lady Zhurong riding out, his brother Meng You feigning surrender. Meng Huo is released again and again and at last submits in his heart.
Those campaigns are the novel’s structure. The number seven comes from the passage Pei quotes. How each capture happens is Luo Guanzhong’s narrative.
Reference: Wikipedia · Meng Huo