For example, if apple get a patent on an idea, and I already had that idea and didn't get a patent for it, and I went ahead and open a company that makes a product based on my idea, can apple sue me for intellectual property infringement? Even if I didn't steal their product secret, but I used my idea to make a product similar to apple's.
If, in your example, Apple filed for the patent before you commercialized your idea then yes you can be sued for infringement. It doesn't matter if you thought of the idea independently or even before the patent filing. If, however, you commercialized or even publicly disclosed your invention prior to Apple's patent application date, then it would constitute prior art and could invalidate the Apple patent. You could still be sued, but would likely win in court.
I should point out that infringement means implementing each and every step of at least one claim in a patent. People often over estimate how broad patents are. Long claims are actually considered narrower than short ones. As always, I suggest consulting with an actual patent attorney in matters of freedom to operate.