Adding all the Matrix Block field types of the same kind to get a total
Twig allows you to add variables just as they were integers. You'll want to setup your totalHours variable before your loop begins so that the totalHours variable is available in the scope outside of the loop itself.

Something like this should work for you:

{# Create a variable to track your total hours #}
{% set totalHours = 0 %}

{% for block in entry.matrixFieldHandle %}

    {% if block.type == 'hoursBlock' %}
        {# Increment your total hours by adding the value
           of your hours block to the current totalHours #}
        {% set totalHours = totalHours + block.hoursFieldHandle %}
    {% endif %}

{% endfor %}

{# Output the result #}
Total Hours: {{ totalHours }}


While I can't test your specific code, here's a generic example that is doing the same thing that will work if you copy and paste it to your template:

{% set totalHours = 0 %}

{% for hours in 0..3 %}
    {% set totalHours = totalHours + hours %}
{% endfor %}

Total Hours: {{ totalHours }}