It's probably not going to be as simple as "tighten up the bolts" - mysteriously unscrewing themselves is a low likelihood .vs. "there's some deterioration in the wall where they attach" which will need to be addressed. Or "Someone sat on the sink and stressed them/the wood they were attached to." So, the sink probably needs to come off to effect a lasting repair, unless you have a child that has discovered tools and unscrewing things who's running around the house unscrewing things at random (don't laugh too hard if you have one that could still reach that stage, or the laugh may be on you.) Sink bolts are inconvenient enough that it's probably not that, though.
Once reattached, caulking is the typical material for sealing up the joint line - look for "kitchen and bath caulk" - it's got anti-mold/mildew additives. Exactly what type (material) of caulk is a matter of opinion (which quickly goes off-topic as being a matter of opinion.)
Edit: Knowing now that the sink was stressed, the first step will be to see what you can find for fasteners - many sinks are mounted via a "bracket" (as @comintern notes) which may not even be visible until the sink is lifted off of it. If you do look under and see bolts or nuts, try tightening them, and (if that works, rather than they just spin in the wall) then give it a week or so to see if the sink stays put before deciding you're done.