The equations ΔE = q + w and ΔS = q/T apply only to a system that undergoes no chemical changes. Then it is no surprise that at constant P and T ΔG = 0, because G is a state function. If there is a reaction, you have to consider the energy and entropy changes between reactants and products.