On the edit distance from a cycle- and squared cycle-free graph