I suggest you to use debounce to detect if a pin has been definitely pressed. You could also test using interrupts (hint: interrupts can happen multiple times even if you "only" pressed once). So either use Arduino's example of debounce or take a look at the Bounce2 library found on their website.
Now that you can check whether or not either button A or B has been pressed, how do you keep track of the voltage to be output? You should use a counter variable that will be incremented when button A is pressed and decremented when button B is pressed. Here is a pseudocode:
if(ButtonA == pressed) counter++; else if(ButtonB == pressed) counter--;
if(ButtonA == pressed)
counter++;
else if(ButtonB == pressed)
counter--;
This counter variable can be used to control the output voltage. Remember that the argument for analogWrite() function on the Arduino Uno is the duty cycle which takes in values from 0 to 255. So analogWrite(0) ≣ 0 Volt and analogWrite(255) ≣ 5 Volt. So at the moment, you couldn't just do analogWrite(counter) because you would need to press 255 times button A!
Instead, you would need a way to convert your counter to reflect the increment you need. You mentioned that it should require 10 presses to reach 5 Volt at the Arduino output, and the easiest way to accomplish this is to use Arduino's Map function. The pseudocode would look like this:
Output = map(counter, 0, 10, 0, 255); analogWrite(Output);
Output = map(counter, 0, 10, 0, 255);
analogWrite(Output);
Now there is one last step! The map function will limit the output voltage from 0 to 5 Volt so everything will be safe; however, the counter is not limited to 0 to 10. This means that even if the counter is at 15 (because you pressed button A too many times) the voltage will be 5 Volt and you would need to press button B at least 6 times to see the voltage go down! So to limit the counter you could easily implement your own function:
if(counter >= 10) counter = 10; else if (counter<= 0) counter = 0;
if(counter >= 10)
counter = 10;
else if (counter<= 0)
counter = 0;
You could also use Arduino's constrain() function which more information can be found on their website.
Hopefully this points you in the right direction.