The way that we obtain categoricity in the second-order Peano axioms is not only about the axioms - it's also about the way we interpret them. We need to be talking about the "second order Peano axioms", rather than first-order Peano arithmetic, for the rest of this answer.
There are two different ways to treat the semantics of second order Peano arithmetic. They are known as "standard semantics" and "Henkin semantics".
In standard semantics, each model can have its own set of "natural numbers" $\mathbb{N}$, and then we interpret quantifiers over subsets of $\mathbb{N}$ as quantifying over all subsets of the set of numbers in the model.
In Henkin semantics, we allow each model to have both a set of "numbers" $\mathbb{N}$ and a set of "sets of numbers", and we interpret a quantifier over subsets of $\mathbb{N}$ as only quantifying over the collection of "sets of numbers" that is in the model. So standard semantics is the same as Henkin semantics with the extra restriction that we only consider models where the collection of subsets of $\mathbb{N}$ is the entire powerset of the set of naturals $\mathbb{N}$ of the model.
Given any set of (possibly second-order axioms) for arithmetic, we can choose either of these semantics. Either way, the set of provable consequences of the axioms is exactly the same. The only difference is in which models we consider.
Given this setup, we can prove that second-order Peano arithmetic with standard semantics is categorical, while second-order Peano arithmetic with Henkin semantics is not.
The key point here is that it is not the theory which is categorical - it is the combination of the theory and the collection of models that we consider that combine to make the theory categorical. If we consider a smaller collection of models, it is easier for the same theory to be categorical.
When we use methods such as compactness or the completeness theorem, we generate models in sense of Henkin semantics that may not be models in standard semantics. That fact explains how the categoricity of second order PA in standard semantics can be reconciled with the compactness theorem - standard semantics can ignore many possible interpretations of a set of axioms.