Electronic structure and physical properties of alkali metal oxides and chalocogenides and magnetism induced by sp dopants