Even if it was legal under the EU at the time? Maybe Ex Post Facto only applies in the US.
Apple (uniquely) having a near zero tax rate is considered illegal state aid to a company. Private companies are supposed to operate on the same terms within each European country.