Recently while self-studying my chemistry book, it dawned on me that metals form basic oxides and nonmetals forma acidic oxides. Why is this?
It is one of the characteristics of the metals as for electrical conductivity, heat conductivity, mechanical properties. All these basically originate from the outer electrons to be "loosely" bound to the nucleus, when compared to non metals. Bonds in metal oxides are ionic, with positive charge on the metal. The same is for their hydroxides, i.e. their compounds containing an OH group. This leads to their basic dissociation in water giving the stable hydroxide ion.
Contrary non metals have tightly bound electrons and are prone to fill their outer shell (Octet rule). On reaction with a non metal as oxygen the situation is therefore a bit more complicated depending on what specific element the non metal is. Non metals oxides are essentially molecular, although the covalent bond is polar to various extents. However, their compounds containing an OH group will retain electrons on the fragment consisting of the two non metals (of which, one is oxygen of course) leading to acid reaction, i.e. H+
(Note that HClO would be better wrote as ClOH).
It should be clear that things are going as ionisation potential - electron affinity - atom size (distance of the outer electrons from the nucleus). For a better explanation I would need more time, it is basically a big chapter of introductory general chemistry, which goes under the name of periodic law and properties of the elements, or something like that.