Which of the following sentences is correct?
I am thinking to invest in stocks.
I am thinking investing into stocks.
I wouldn't use either one; I'd say "I'm considering investing in stocks". One does not "invest into" anything (in my experience). The first sounds at best somewhat stilted.
Your first sentence is a fairly common structure, but it is somewhat informal, to say the least. I would not recommend non-native speakers experimenting with such non-standard forms.
The second sentence is simply ungrammatical.
The standard phrasing is...
I am thinking of investing in stocks.
When you are considering a possibility or advantages of doing something, you use think of.
He was thinking of becoming a zoologist.
I am thinking of investing my money.
I am thinking of investing in stocks.
"I am thinking investing into stocks" needs a second part to make it grammatically valid. For example:
Which is contracted from "thinking that/[of] how investing...".
But, in general, there are better choices to express the same meaning.
Funny, I had thought it was
"I am thinking about investing in stocks."
But maybe that's too colloquial?