Commutation when minimal and characteristic polynomial agree
Hint: 1) Show that there is a vector $e$ such that $(e,Ae,A^2e,\dots,A^{n-1}e)$ is a basis (this is another standard exercice).
Write $Be = \sum_{i=0}^{n-1} a_i A^i e$.
2) Show that $B$ and $\sum_{i=0}^{n-1} a_i A^i$ agree on the basis.
This becomes quite easy viewing a vector space equipped with a linear operator$~T$ as a module over the ring $K[X]$ (with $X$ acting as $T$), especially using the structure theory of finitely generated modules over a P.I.D. (here $K[X]$). If one chooses $A$ to give the linear operator$~T$ defining the $K[X]$-module structure, then the commutation of $B$ with $A$, and hence with any polynomial in$~A$, precisely means that $B$ defines an endomorphism of the so defined $K[X]$-module.
The argument now consist of two parts: (1) equality of characteristic and minimal polynomials implies that the $K[X]$-module is cyclic: for some fixed generating vector $v_0$, every $v\in V$ can be written $v=P\cdot v_0$ for some $P\in K[X]$; (2) an endomorphism of a cyclic $K[X]$-module is given by multiplication by some fixed $Q\in K[X]$. (In the end this will mean that $B=Q[A]$.)
The proof of (2) is straightforward: calling the endomorphism $\beta$ and writing $\beta(v_0)=Q\cdot v_0$, one has, for any $P\in K[X]$, that $\beta(P\cdot v_0)=P\cdot\beta(v_0)=P\cdot Q\cdot v_0=Q\cdot P\cdot v_0$, which shows that $\beta$ coincides with multiplication by$~Q$. (In the application $\beta$ is multiplication by the matrix$~B$, which coincides with multiplication by $Q[A]$, so this must be the same matrix.) (This part corresponds to the answer by user10676, with $Q=\sum_{i=0}^{n-1}a_iX^i$ of that answer.)
The proof of (1) is easy with the mentioned structure theorem, which says that $V$ decomposes as a direct sum of cyclic modules, with the minimal polynomial of each summand dividing that of the next. Then the last minimal polynomial annihilates all summands and is therefore the global minimal polynomial; the characteristic polynomial is the product of those minimal polynomials. So minimal and characteristic polynomials coincide (if and) only if the decomposition contains no more then one (non-trivial) module.
If one wants to reason without using the structure theorem for f.g. modules over a P.I.D., (1) is still quite plausible. For every vector $v$ the minimal degree monic polynomial $M$ such that $M\cdot v=0$ divides the minimal polynomial$~\mu$, and for every strict divisor $D$ of$~\mu$ the subspace annihilated by $D$ is a proper subspace; this suggests that for most vectors $v$ one has $Q=\mu$, and given that $\deg(\mu)=\dim(V)$, this means that $v$ generates $V$ as a cyclic module. Indeed there are only finitely many divisors$~D$, so if $K$ is an infinite field this amounts to a valid argument. An complete argument valid for all fields is a bit more work, but can be found in this answer.