In the quest to achieve “double carbon” goals, the urgency to develop an efficient Integrated Energy System (IES) is paramount. This study introduces a novel approach to IES by refining the conventional Power-to-Gas (P2G) system. The inability of current P2G systems to operate independently has led to the incorporation of hydrogen fuel cells and the detailed investigation of P2G’s dual-phase operation, enhancing the integration of renewable energy sources. Additionally, this paper introduces a carbon trading mechanism with a refined penalty–reward scale and a detailed pricing tier for carbon emissions, compelling energy suppliers to reduce their carbon footprint, thereby accelerating the reduction in system-wide emissions. Furthermore, this research proposes a flexible adjustment mechanism for the heat-to-power ratio in cogeneration, significantly enhancing energy utilization efficiency and further promoting conservation and emission reductions. The proposed optimization model in this study focuses on minimizing the total costs, including those associated with carbon trading and renewable energy integration, within the combined P2G-Hydrogen Fuel Cell (HFC) cogeneration system. Employing a bacterial foraging optimization algorithm tailored to this model’s characteristics, the study establishes six operational modes for comparative analysis and validation. The results demonstrate a 19.1% reduction in total operating costs and a 22.2% decrease in carbon emissions, confirming the system’s efficacy, low carbon footprint, and economic viability.