The Tds relations I refer to are, $$Tds = du + Pdv$$$$Tds = dh - vdP$$
The first equation is derived (assuming internally reversible process) from the definition of entropy $ds = \delta Q/T$ and the idea that heat supplied is used to do work and increase internal energy. Note that work here refers to work at constant $P$.
The second $Tds$ equation is obatained using the definition of enthalpy as $h = u + Pv$ => $dh = du + Pdv + vdP$ and substituing $du + Pdv$ with $Tds$ as per the first equation => $dh = Tds+vdP$. Note that unlike the first relation, $P$ is allowed to vary here (the term $vdP$ appears as a result).
How is this substitution correct where we assume $P$ to be constant as well as a variable within the same relation?
The above approach to deriving the Tds relations is from Thermodynamics: An Engineering Approach, Cengel and Boles, 8e.