The InSight mission's high-quality seismic data and cosmochemical models have demonstrated that Mars has a volatile-rich core. It is proposed that Mars formed early, before the solar nebular gas dispersed, and/or it accreted volatile-rich material to account for its volatile-rich interior. The early accreted Mars must have gravitationally attracted proto-atmosphere from the surrounding solar nebula. If its building blocks were rich in volatiles, it might have acquired impact-generated atmosphere during accretion. By considering the decay energy of the short-lived radionuclide (SLR) 26Al and the blanketing effect of the primordial and impact-generated atmosphere during the initial 10 Ma of the formation of the solar system, we present the results of numerical simulations carried out for the early thermal evolution and core formation of Mars. To explain the formation of a large iron core of Mars as suggested by the seismometer of InSight mission, we considered the 60% EH- and 40% CI-chondrite composition for the building blocks of Mars. The blanketing effect of impact generated H2O + CO2+CO + H2 atmosphere caused the melting of surface silicates to form magma ocean at surface. We thoroughly examined the effects of several variables on the timing of complete core formation, including the initial water content in the accreted material, timescale of onset of accretion after the formation of CAIs, duration of accretion, absorption coefficient of CO2, efficiency of degassing of volatiles, and melting temperature. The results of present study show that the decay energy of SLR 26Al caused the widespread heating and melting of interior of Mars. For complete core formation, Mars must accrete within the first ∼2 Ma in order to explain the volatile-rich core. Further, the timescales of core formation were found to be strongly dependent on the assumed melting curve. For longer timescales of accretion, the interior of Mars experienced incomplete differentiation even by assuming high water content in the accreted material and larger absorption coefficient for CO2. However, Mars does not have to accrete within 2 Ma for the core to fully develop if the Rayleigh- Taylor (RT) instability is present in the dense metallic layer on top of the undifferentiated interior. A short accretion time is only valid if RT-instability is neglected. Hence, we expect that the volatiles in the magma ocean could also be transferred to core by Rayleigh-Taylor instability. We also parameterized the thermal influence of gravitational heat produced during the differentiation of Mars to study its influence on the thermal evolution of the planet. The outcomes of the present work have implications to explain the timing of partition of volatiles in the Martian interior and formation of an early atmosphere on Mars.