You need a single hand free for both Material and Somatic Components to be met
#You need a single hand free for both Material and Somatic Components to be met TheThe Rules on Spellcasting specify how Material and Somatic components work:
Somatic Components
Material Components
Specific Questions
##Specific Questions UsingUsing these guidelines, let's look at the questions presented:
###Question 1
Question 1
###Question 2
Question 2
Reviewing other objects in hands
##Reviewing other objects in hands Let'sLet's take a look at the various options provided in the question and how they work in determining if and when you have a free hand.
Quarterstaff only
###Quarterstaff only TheThe wizard can release one hand from the weapon to be free for Somatic/Material components without any issues. See this question.
Dagger and Component Pouch
###Dagger and Component Pouch ThisThis is easier than you think it is! You don't need to 'hold' your component pouch/focus - but you do need to be able to touch it. In this case, you can wield your dagger in one hand and then have your free hand access your Material/Somatic Components during the casting.
Shield and Dagger
###Shield and Dagger IfIf you've somehow got a way as a wizard to cast spells with a shield in one hand and you've got a weapon in another you're going to come up against some obstacles.
Both hands occupied
###Both hands occupied SomeSome classes resolve the Material component of Sword and Board (Cleric and Paladin), but if you don't then you need to free up a hand in order to cast a spell with either a Somatic component or both Somatic/Material components.