How were quarks occurred ?
(in the early universe)
Quarks formed approx during the electroweak epoch or just after during the quark epoch.
There is some discrepancy on the exact moment depending on which article you read.
At first they are free particles till the Higgs field supplies sufficient mass and the temperature cools enough to form hadrons.
Google high energy particle physics or Early universe particle physics. Keep in mind the discepancies between articles. Most of them will involve Susy.
quarks can also spontaneously form from energy (as long as conservation laws are met)
There's no simple answer, you really have to study basic particle physics to understand quarks. Here's a basic guide that should give you the basic concept: http://teachers.web.cern.ch/teachers/archiv/hst2000/teaching/resource/lessons/basic/notelist.htm
Quarks are elementary particles and so they didn't "form" at any point following the big bang -- they were already in existence along with the leptons and gauge bosons.
In the very early, hot universe, free quarks existed as part of the quark-gluon plasma. The strength of the interaction force between quarks drawing them together (the strong nuclear force) is weaker at higher temperatures, so in the early, hot universe quarks don't interact very much. However, as the universe cools and the strong nuclear force becomes relevant, quarks quickly form bound states like mesons and baryons.
Separate names with a comma.