How does one make the jump from merely "knowing" the steps required to prove something to being able to deeply understand them? I can often look at a proof/see a professor explaining it and I am convinced that the proof works, but I don't understand it well enough so that I *would have been able to come up with a similar idea myself had I not seen the proof.* Often the proof just "happens to work" and I'm not able to see why it is the *best* way (or one of the best ways) to prove the assertion. 

How does one make the jump from knowing the steps in a proof (and getting why they work) to truly understanding the ins and outs of it?

Edit: A better idea of what I mean by understanding - Say you come up with a basic idea (a very rough plan to prove something) but you aren't able to formulate the argument fully; then you see the a proof in a book and it essentially takes your idea and proves the thing rigorously. How does one understand the proof well enough so that one would have been able to see the idea themselves had they, hypothetically, forgotten the proof but somehow retained the "understanding" (and lost the "knowledge")?

An example. Let's take a proof of a very basic claim in real analysis: every compact set in $\mathbb{R}^{n}$ (in fact in any Hausdorff space) is closed. 

Let $K \subset \mathbb{R}^{n}$ be compact. We want to show $\mathbb{R}^{n} \setminus K$ is open. Pick $x \in \mathbb{R}^{n} \setminus K$. It suffices to show that $B(x, \varepsilon) \subset \mathbb{R}^{n} \setminus K$ for some $\varepsilon > 0$. Then, for all $k \in K$, there is $\varepsilon\_{k} > 0$ and $\varepsilon'\_{k} > 0$ such that 
$$
B(x, \varepsilon'\_{k}) \cap B(k, \varepsilon\_{k}) = \emptyset
$$
The collection $\{B(k, \varepsilon\_{k})\}\_{k}$ is an open cover of $K$ and we can find a finite subcover $\{B(k\_{i}, \varepsilon\_{k\_{i}})\}\_{i=1}^{N}$. Next, we can pick 
$$
\varepsilon= \min\_{1 \leq i \leq k} \{\varepsilon'\_{k\_{i}}\}
$$
and $B(x, \varepsilon) \cap K = \emptyset$, so we have shown that $K$ is closed. 

Now, this isn't a super hard proof and only makes use of basic facts, but seeing this is a beginner can be hard (and was for me when I first saw it). I got what we were doing, but I didn't see deeper. But somehow while reproducing this proof right now, the idea of "separating the set and the outside using balls" was intuitive to me: what made me jump from "knowing" to "seeing/understanding" what had to be done?