Welcome to Cruise-Chat!
Sorry to hear you got ill during the cruise. A cruise ship is just like any other public environment. You can catch colds and other types of illnesses by being around other people. Everyone in my office at work now has a cold, (including myself), and we don't know where it came from.