apt-get -- remove triggers a package install?

The package php5 depends on having either apache2 or cgi installed.

The two main options to satisfy this dependency is either libapache2-mod-php5 or php5-cgi.

If you remove one, the system will install the other, otherwise php5 would have an unmet dependency.

You can see the dependencies at php5 in the Ubuntu packages database.