Because the rule for partial differentiation is to calculate the derivative using the formula given and
not looking through any variables that may themselves be functions of other variables. In your alternative approach you are treating t as a function of p,
looking through that function definition and including as part of the partial derivative any dependencies on p that you find . You are not supposed to look through like that. Treat each variable in the formula given for y as if it is an atomic variable that has no dependence on any other variable.
Unfortunately, the curly-d notation for partial differentiation tends to obscure this important principle because it makes it look like partial differentiation is something you do to a
variable. It isn't. It's something you do to a
function.
Total differentiation can be something we do to a variable, but not partial differentiation.
See my Insights not on this topic, which may help clarify:
https://www.physicsforums.com/insights/partial-differentiation-without-tears/