If quarks can't be isolated in the first place, how did they become confined in the early universe? On one hand, we know that quarks cannot exist in isolation. This is because the energy required to dissociate a quark-antiquark pair in a meson (or quarks in a hadron) will create a mesons (or hadrons) if we try to separate. For example, see these explanations in the short videos here and [here]. 
What about the situation in the early universe? I heard that there was a phase when the quarks got confined within the hadrons and mesons indicating they were free before that. How does it fit with the explanations given in the videos? How does it fit with the quark-gluon plasma?
 A: Quarks and gluons are modeled with quantum chromodynamics.The electromagnetic force gets stronger  for high energies , the strong (QCD) and weak force weaker, what is called asymptotic freedom.

In particle physics, asymptotic freedom is a property of some gauge theories that causes interactions between particles to become asymptotically weaker as the energy scale increases and the corresponding length scale decreases. 

This can qualitatively be seen in this plot :
 
This shows 1/strength of the three interactions, strength is inversely connected with the coupling constant in the calculations using perturbation theory.  The electromagnetic gets stronger with energy, the  weak and the  strong get weaker. This change in coupling constants has been measured at LEP  experiments, for the weak and electromagnetic.
The crossover of the weak and the electromagnetic gave rise to the electroweak theory , with the higgs , where for high energies  they are one force, and then symmetry breaking makes the two separate forces  we measure at the energies we have in the lab.
The almost overlap of the QCD running coupling constant with the other two, gave rise  to a model of unification of all three forces at very high energy, making one force to describe all particle interactions . These are the energies of the quark gluon electron etc ( a lot of etc since supersymmetry enters)  plasma of cosmology, and of course it is model dependent.
This is a very sketchy description of the models used in particle physics for very high energy interactions. One should enter into the mathematics of the models for a serious study.

If quarks cannot be isolated 

this should be qualified with "at energies available in our laboratories"

what does it mean to say that they got confined at the hadron era?

In cosmological models as the big bang one, all the energy of the universe is concentrated in a very small "volume", where to start with no particles of the standard model exist, and as time progresses they exist  asymptotically free, in a soup.

As time progresses the universe cools and the hadron era is reached where by 0.01 seconds protons have been formed, and quarks and gluons have to be confined within hadrons.
A: Before the quarks were “confined” they were free in that each one could be essentially anywhere. At some point things cooled enough so that each quark settled into a bound state as say part of a proton. At high temperature there’s so much energy shared among particles that bound states are not likely to occur. Below a certain critical temperature the bound states are suddenly much more likely. This is a phase change similar to freezing. 
