#::O=C=O::# is the typical Lewis structure. When we assign charge we conceive that a covalent bond is shared by the 2 participating atoms. Therefore, the central carbon shares 4 electrons with the oxygens; there are 2 inner core electrons, and thus on #C# there are 6 electrons that balance the 6 positively charged protons of the carbon nucleus. Carbon is neutral. For oxygen, #Z=8#, there are 2 lone pairs (#4xxe^-#) whose charge devolves solely on #O#, 2 #e^-# from the double bonds (i.e. again #1/2# of the bonding electrons), and 2 inner core electrons. Thus these 8 electrons in total balance the nuclear charge.
Can you do the same thing with nitrate anion, #NO_3^-#? Where does the formal negative charge lay (there is also a formal positive charge!).