Anthony Russell - I agree with JohnFx. Petroleum is used in making many things such as asphalt, road oil, plastic, jet fuel, etc. It's also used in some forms of electricity generation, and some electric cars use gasoline as a backup form of energy, petrol is also used in electricity generation outside of cars. Source can be found here.
But to answer your question of why shares of electric car companies are not always negatively related to one another deals with supply and demand. If investors feel positively about petroleum and petroleum related prospects, then they are going to buy or attempt to buy shares of "X" petrol company. This will cause the price of "X", petrol company to rise, ceteris paribus. Just because the price of petroleum is high doesn't mean investors are going to buy shares of an electric car company. Petrol prices could be high, but numerous electric car companies could be doing poorly, now, with that being said you could argue that sales of electric cars may go up when petrol prices are high, but there are numerous factors that come into play here. I think it would be a good idea to do some more research if you are planning on investing.
Also, remember, after a company goes public they no longer set the price of the shares of their stock. The price of company "X" shares are determined by supply and demand, which is inherently determined by investors attitudes and expectations, ultimately defined by past company performance, expectations of future performance, earnings, etc..
It could be that when the market is doing well - it's a good sign of other macroeconomic variables (employment, GDP, incomes, etc) and all these factors power how often individuals travel, vacation, etc. It also has to deal with the economy of the country producing the oil, when you have OPEC countries selling petrol to the U.S. it is likely much cheaper per barrel than domestic produced and refined petrol because of the labor laws, etc. So a strong economy may be somewhat correlated with oil prices and a strong market, but it's not necessarily the case that strong oil prices drive the economy..I think this is a great research topic that cannot be answered in one post..
Check this article here. From here you can track down what research the Fed of Cleveland has done concerning this. My advice to you is to not believe everything your peers tell you, but to research everything your peers tell you. With just a few clicks you can figure out the legitimacy of many things to at least some degree.