Sure, that could happen but expanding to Mars would improve the odds of survival (because an extinction event on both planets simultaneously is less likely than one just on Earth). Earth is currently a so-called "single point of failure" (SPOF)[0] for humanity and all forms of life that we know of.
If we spread humanity and life to Mars and beyond (in an independent/self-sustaining way and not just as an outpost that depends on Earth), neither of the planets alone is SPOF anymore. The solar system is still SPOF but even the close galactic neighbourhood might not be of much help against events that threaten the solar system as a whole (see e.g. about the effects of a gamma-ray burst [1] in our 'proximity'. Note when reading [1] that 1 kiloparsec = 3200 light years! [2]).
[0] https://en.wikipedia.org/wiki/Single_point_of_failure
[1] https://en.wikipedia.org/wiki/Gamma-ray_burst#Effects_on_Ear...