The best way to count how many edges has the figure is by looking at the figure separately, each solid from the top.
Let's start counting how many edges have the hexagonal prism.
As you can see, if we view the hexagonal prism from the top we can count easier, each purple point represents the vertical edges, we have 6 of them, and if we count all the black lines we have 6 edges but remember that in the bottom there are another 6 edges, so in total, we have 6+6+6= 18 edges if we only count the edges in the hexagonal prism.
Now, lets count the edges in the hexagonal pyramid:
In the hexagonal pyramid, we can count all the black lines, and we see that we have 12 edges, but remember that the edges on the outside of the figure are the same edges of the hexagonal prism, so we only have 6 edges.
Finally in total we have 18 edges + 6 edges = 24 edges.
The answer to the question is A.