The most basic difference between a Shakespearean comedy and tragedy is that comedies have generally happy endings where most characters live, while tragedies have at best bittersweet endings and protagonists who die. However, there are also more subtle differences, and some of Shakespeare's plays fall into neither or both categories.
Comedies tend to focus more on situations than characters. This keeps the audience from empathizing with the plight of the characters, which can detract from the humor of the circumstances comedic protagonists find themselves in. Multiple plot lines that see characters separated and reunited, use of puns, identity confusion, family conflicts and young love are also common signs that a play is a comedy.
While tragedies share certain characteristics with comedies such as sometimes focusing on young love and conflict between families, other elements are more distinct. Tragedies are much more serious, focus on characters over the plot to make the audience emotionally invested in the protagonist's inevitable loss and emphasize characters' honesty or lack thereof. They also tend to follow Aristotle's older definition of a tragedy in which a hero of noble birth is brought to ruin by his or her tragic flaw, the one imperfection in the individual's otherwise sterling character.
It's also worth noting that other categories of Shakespearean drama exist. Histories, for example, chronicle the exploits of the English royal family and tend to focus on the progress of society; they strike a balance between tragedy and comedy. Romances, meanwhile, usually involve love and are serious stories that end happily, while tragicomedies combine elements of both comedy and tragedy.