Actually both countries have tremendous geopolitical importance that also affects economy even considering energy.
For starters if you look at the world map they are in a very major and important route that passes all through Asia connecting Mediterranean sea (Europe) to all over Asia (including China and Russia) from land. In fact Syria has a couple of very strategically important ports that Iran, China and Russia are using for their trades. As you may know the first step in economic point of view is security of routes.
Additionally when a region is destabilized, all that chaos pours into the whole neighborhood. So for example when Syria is being destabilized and it is US that is doing the destabilization, their forces are going to be hit all around the region which means for example Qatar and Saudi Arabia are hit and that threatens oil and gas supplies.
The importance of Afghanistan can be seen from the fact that USA has not forgotten it. Very recently they did a drone attack killing Ayman al-Zawahiri and the air strike was done using air route that passes via Pakistan. USA has complete control over this region via Pakistan and Afghanistan until Taliban took complete control of Kabul.
The last Prime minister of Pakistan did show eyes to USA and other western countries and was quickly removed from power using Pakistan army. Afghanistan is important as it allow USA to sit on borders of China and keep a close eye on Russia also.