Origin of magnetic inhomogeneity in Cr- and V-doped topological insulators