Why is this pushdown automaton for some palindromes right?
PDAs are nondeterministic. Although you have found a valid computation which does not lead to an accept state, a PDA is said to accept its input if there is some valid computation which does lead to an accept state.

In this case (input $111$), an accepting computation is:


$q_1 \to q_2$, stack: $[\$]$
$q_2 \to q_2$, stack: $[\$, 1]$
$q_2 \to q_3$, stack: $[\$, 1]$
$q_3 \to q_3$, stack: $[\$]$
$q_3 \to q_4$, stack: $[]$