It would be also possible to say the second sentence as 'I loved swimming.' and vice-versa (using 'used to' with the first one). It depends on what one wants to say in English. Usually, the "pretérito imperfeito" in Portuguese is used to actions that happened in the past in a regular basis but not any more (in the present). Your can find more information here...
What determines the use of the infinitive and the gerund after "like" has nothing to do with Portuguese. If you want to impart a general meaning to the statement, use a gerund. However, you want to reference a specific occasion, use the infinitive.