To my knowledge, the most expeditious way to prove this is to use
$f$ is continuous on $X$ if and only if for any open set $V \subset Y$, $f^{-1}(V)$ is an open set in $X$.
where $X$ and $Y$ are domain and codomain of $f$ (can be arbitrary metric space).
Based on this statement, to show $f^{-1}$ is a continuous mapping of $B$ onto $A$, it is sufficient to show that for any open set $V \subset A$, $(f^{-1})^{-1}(V)$ is an open set in $B$, that is, $f(V)$ is open in $B$.
Now since $V$ is open in $A$ and $A$ is compact, $V^c \cap A$, as a closed subset of $A$, is compact (use the theorem that any closed subset of a compact set is compact). Since $f$ is continuous, $f(V^c \cap A)$ is compact and so is closed in $B$ (use the theorem that continuous mapping of any compact set is compact). Now since $f$ is one-to-one and onto, $f(V)$ is the complement of $f(V^c \cap A)$, hence is open in $B$.
For the counterexample, consider $A = [0, 1] \cup (2, 3]$, which is not compact, and define $f$ as follows:
\begin{align}
f(x) = \begin{cases}
x & x \in [0, 1] \\
x - 1 & x \in (2, 3]
\end{cases}
\end{align}
$f$ is a one-to-one and onto function of $A$ to $B = [0, 2]$, in addition, $f$ is continuous at every point of $A$. It is easily to get that
\begin{align}
f^{-1}(x) = \begin{cases}
x & x \in [0, 1] \\
x + 1 & x \in (1, 2]
\end{cases}
\end{align}
Hence $f^{-1}$ is not continuous at $1$! (a jump occurs here).