The urgent global concern regarding climate change has highlighted the necessity for transitioning to power generation with zero carbon emissions to promote a sustainable and environmentally conscious society. A crucial element in this transformation is reducing our dependence on the primary grid, which is predominantly powered by fossil fuels, natural gas, and coal. An innovative strategy for achieving this essential transition is through peer-to-peer energy trading (P2PET). However, the effectiveness of P2PET relies on successfully aligning the energy-related objectives of its participants. Identifying and effectively addressing these goals is a significant challenge. In response, this paper introduces a game-theoretic framework designed to encourage subscribers to engage in P2PET, both in islanded microgrids and interconnected grid configurations. Our methodology begins by introducing a model that captures the core energy-related objectives of both energy producers and consumers. This model is supported by a layered architectural framework tailored for peer-to-peer (P2P) marketplaces, enhancing the identification and classification of existing technologies in this domain. Following this, we delve into the formulation of an extended-form game rooted in non-cooperative game theory. We systematically evaluate the presence of strict Nash equilibria within this game-theoretic structure. To promote active engagement and trading in the peer-to-peer energy market (P2PEM), we introduce an innovative energy allocation policy. This policy is strategically devised to ensure the inclusion of every subscriber in the market, irrespective of fluctuations in supply and demand dynamics. Our proposed P2PET scheme is tested on a representative system, specifically a 14-bus IEEE network, incorporating 8 energy producers and 11 consumers as active participants in the market. By conducting an extensive series of tests, we accurately evaluate the design's performance. The results, compared to previous studies, show a significant reduction in consumer energy bills, ranging from 33 % to 7 %. This convincing result underscores the effectiveness and robustness of our proposed energy trading framework. In a world grappling with the imperative to transition to sustainable energy practices, our game-theoretic approach to incentivizing participants in P2PET emerges as a pivotal contribution. It demonstrates tangible benefits, promotes green energy production, and encourages responsible energy consumption.