High school student scooped by PhD student in the same lab
The situation that you describe sounds like extremely unusual and improper behavior on the part of the professor.  The graduate student is part of the problem, but the real responsibility lies with the professor who committed two major instances of misconduct:


Allowing the graduate student to co-opt your work without giving you credit.
"Giving" you authorship on a paper that you did not participate in.


Whether or not you should have been first author is not necessarily clear---one would have to know a lot more about the final form of the work to judge for certain.

As for your actions, I think that the primary actions that you took (raising the issue with the professor, then walking away from the situation when the problem was not addressed) were appropriate.  I think that you should probably feel uncomfortable about the paper that has your name on it when you don't feel you deserve authorship.  You can get that fixed by the publisher, if it makes you uncomfortable enough.

I think that you are making a mistake, however, in allowing this experience to sour you on academia.  Unethical people who will take advantage of you can be found in every profession, and in academia at least there are clear rules on what the ethics are supposed to be.  You won't necessarily find that in the business world, where it is often considered ethical to exploit people for money (see: fiduciary duty to stockholders).