Are stocks prices included in GDP?
No, they aren't. Buying stock is a transfer of asset not a purchase in a sense understood by macroeconomists.
My question is: does this rule apply to stock market. Is this statement true for example: when a company goes IPO, issued stock certifications (when sold) increases GDP. But when we buy stocks from another seller in stock markets they does not. Also what happens to GDP when the price of a particular stock increase or decrease?
The rule that only final expenditure on goods and services counts applies to all market exchanges. However, as explained in the first part sale of stock is not sale of goods or services. Stocks are neither final good or service, they are transfers of wealth from investor to company.
IPOs do not increase GDP directly. GDP will increase once the company spends the money on investment (but note in economics buying stock is not considered investing - spending on capital goods or accumulating inventory is investing from macro perspective) or once it produces some goods or services with that money which are then bought by final consumers. Otherwise GDP is not affected.
Hence stock prices do not directly increase or decrease GDP. They can affect GDP in a sense that level of investment in an economy depends on return people get on saving. Return on saving in form of stock depends in turn on change in the stock prices over time. Of course, there is some nuance to it but I won't explore it here as it is only tangentially related to question about calculation of GDP. But the point is that stock prices do not directly factor into calculation of GDP.