Natural gas and renewable energy sources make up an increasingly large proportion of power generation due to their being environmentally friendly. Because of the intermittent and fluctuating output of renewable energy sources, the emerging technology of power-to-gas (P2G) units is of great significance to alleviate. This paper focuses on the coordinated optimization of the combined gas and electricity network (CGEN) system with bidirectional energy conversion. Gas-fired power generation (GPG) plants and P2G are considered as linkages between the two networks. A unified CGEN mathematical model is established with the minimum operation cost as the objective function. The injection and production process of underground natural gas storage (UNGS) is also taken into consideration that is not available in other literature. Variables such as the output of P2G and gas-fired power generation plants, the supply of UNGS, and the wind curtailment are optimized correspondingly. The improved 24-node power grid (PG) and Belgium 20-node natural gas pipeline network (NGPN) are adopted to test the validity and capability of the proposed model, and then we compare the results CGEN model with the single Belgium NGPN to analyze the impact on the NGPN. Moreover, we adopt a coupled operation system of a 6-node power system and a 7-node NGPN to further analyze the influence of P2G on the CGEN. The results show that compared with the system without P2G, the total operating cost of the system is reduced by 9.39%, the natural gas load shedding is reduced by 26.1%, and the wind curtailment is reduced from 326 MWh to zero.