Several literature works have highlighted that the expansion of electrification across all sectors is a crucial factor in promoting the transition of energy systems towards carbon neutrality by mid-century. However, polygeneration systems through the appropriate integration of different renewable energy sources are expected to play an important role in such transition by effectively reducing the total primary energy demand, as explored in the present work for an energy community (EC) case study. Therefore, this paper presents the optimal synthesis, design, and operation of an EC system working under three different scenarios and evaluates the trade-offs between the total annual costs and greenhouse gas (GHG) emissions (evaluated as CO2 equivalent emissions). The EC is a District Heating and Cooling Network (DHCN) composed of nine third sector buildings in the northeast of Italy. The DHCN superstructure includes several possible energy supply components for each EC member, a central unit, and heat and/or cooling connections between buildings. Moreover, peer-to-peer electricity sharing is allowed among EC members, through a local electricity grid, before buying/selling electricity from/to the main grid. The superstructure was optimised through a mixed integer linear programming (MILP) model considering a multi-objective optimisation for the total annual cost (for owning, operating, and maintaining the entire system) and the total annual CO2eq emissions as the objective functions. The three scenarios through which the EC system is optimized and evaluated consider the type of consumed gas (natural gas or biomethane) and the electricity consumption configuration (on-grid or off-grid). Results have shown that the cost (per ton of CO2eq) to reduce emissions is too high if the European Union's carbon market is considered. This was especially critic for the natural gas scenario, where the cost per ton of CO2eq (between two optimal solutions) was about four times higher than its cost on carbon market.