Muon anomalous magnetic moment in supersymmetric scenarios with an intermediate scale and nonuniversality