Analysis of the wake dynamics of a confined square cylinder