It’s difficult to know why, precisely, a cottonee may be wandering that close to you without seeing it for myself, but given the fact that it’s been storming and the fact that it’s not with its herd, it may be safe to say it perceives you as safety. That is to say, you may be the first human or otherwise trustworthy-looking creature it’s come across, so it’s trying to get your attention because it’s simply lost and scared.
If possible, try to get it to come to you, but don’t catch it. Remember, it could be scared, which means it could want to go home. It may not be able to fully control its flight path, so if you have a flying-type or a pokémon with psychic abilities or Vine Whip, try to rope it down. Once it’s within reach, grasp it on its sides, beneath its wings, so it doesn’t get startled by your touch. Slowly move it into your arms and feel its weight. It should be about two pounds, or the weight of a loaf of bread. If it feels lighter, it may be starving or dehydrated, and it should be taken to a pokémon center immediately.
Of course, it’s wise to take the cottonee to a pokémon center either way. It’s just that these kinds of health issues may also explain why this cottonee is following you. Otherwise, it’s good to have a Nurse Joy look it over and treat it for any possible injuries or mental shock from the storm.
You may leave the cottonee here if you’d like, and Nurse Joy will likely keep an eye out for any cottonee flocks to return it to the wild. However, you also have the option of escorting cottonee to its flock yourself. Just be warned that cottonee can travel across many miles in a single day and are reliant on wind currents to get from place to place. This cottonee’s flock may be far, far from where you are, and in any case, it’s important to keep this in mind to avoid having the cottonee inadvertently sail away from you. That is to say, anchor it if you wish to take it with you, and be warned that if you’re going to actively look for its flock, you may be looking for quite some time.
However, it’s also important to take a good look at how the cottonee reacts to you. If it seems attached to you (excited whenever you walk in, sad whenever you’re about to leave, and so forth), it may have decided that you seem interesting for some reason. Why that is may be for any number of reasons. Perhaps it sees you as a food source, perhaps it needs training (either for itself or to become a whimsicott), perhaps it likes your pokémon, or something else entirely. Regardless of the reason, if it looks particularly interested in you, this may be taken as an opportunity to catch it. I would do so and then try to figure out the reasoning behind it, as the reasoning will become apparent pretty quickly after the cottonee joins your team. That and it’s likely that the reasoning itself isn’t exactly bad—just more of an incentive to take care of it, so to speak.