Table with relation to two others (three-way relation?)
There is a third option:

Create tables visit_attribute and visit_action_attribute with name and value columns in each (and drop the attribute table altogether).

This removes the possibility of a given attribute being linked to both a visit and a visit_action, with no need for id columns with NULL values.