Solving certain matrix equations by means of Toeplitz computations: algorithms and applications