In my book,“general chemistry” by Ebbing and Gammon,it is stated that at constant pressure Qp=∆U+P∆V=∆H.
This is correct in the absence of electrical and mechanical work (e.g. the equality breaks down for a battery or a fuel cell doing electrical work, or shaft work heating up the reaction mixture).
How come can q equal ∆H?
You can express the change in enthalpy as an extensive quantity (changes with the size of the reaction) or, in the case of molar enthalpy, an intensive quantity (does not depend on the amounts reacting). The equation above refers to enthalpy, the extensive quantity (with units of e.g. kJ). On the other hand, enthalpy of formation usually refers to the intensive quantity and should be called molar enthalpy of formation (with units of e.g. kJ/mol).
For the enthalpy of reaction, things are a bit fuzzy in introductory textbooks, either interpreting it as extensive or intensive. If it is used as intensive quantity, a change in the coefficients of the reaction (i.e. doubling or halving all coefficients) will change the value of the molar enthalpy. This is a bit surprising.
The only occasion at which q=∆H is when the moles of the limiting reagent in the thermodynamic equation is 1, such that q=∆H/n.
If ∆H is understood to be the molar enthalpy of reaction, you would have to multiply by the amount that reacts, not divide, i.e.
$$q = \Delta_r H \cdot n$$
where $n$ is the amount that reacts (i.e. the change in the amount of any species divided by its stoichiometric coefficient).
What does constant pressure has to do with this equality? Because if we assume such equality of Qp=∆U+P∆V=∆H at constant pressure, then it is also valid at constant volume when ∆V=0 such that Q=∆U=∆H.
That is a different question, and there are good pointers in the comments to learn more. The generally valid equality is:
$$ \Delta H = \Delta U + \Delta (P V)$$
so $P V$ changes when the pressure is constant and the volume changes, or when the volume is constant and the pressure changes (or when both change). This equation refers to enthalpy, not molar enthalpy, as you can figure out from dimensional analysis ($P V$ has dimensions of an energy, not a molar energy).