This happens even to people who know how to search the literature and have some experience. Often it happens because when one starts thinking about something new, one understands little, and only once one has understood some things is it possible to realize that others have also already studied and understood them. Talking to other researchers, attending conferences, reading widely, etc. are all activities that help avoid rediscovery, but obviously they are all hard for a high school student.
Generally, one should not publish results that are already available in the literature, particularly if one's methods are in the fundamental aspects the same as those used previously (moreover, it will usually be quite difficult to publish results that are already known). There are exceptions, as sometimes one has a new take on an old result, or a better way of obtaining it, or sometimes one can adapt one's work into an expository account of the already known results that could be published (this will work only if those results have generated a fair amount of interest). If one succeeds in publishing already known results, it could generate in others' minds doubts about one's honesty, although it certainly happens that people innocently rediscover and publish known results (I know several examples). Often this occurs when they rediscover them in a context different from that of the original discovery (e.g. a graph theorist discovers some algebraic fact, and publishes it in a graph theory journal, although some experts in the relevant algebra would recognize it as a special case of something they already know).
However, there is a positive side to such rediscovery, and this is the most important aspect for a high school student.
The positive aspect of rediscovery is the following. First, that one has rediscovered published results should confirm one's sense (that one ought to have already) that one is doing something interesting (this is important for one's confidence). Second, any interesting results admits extensions, variations, further developments, etc. so such rediscovery provides a base for further work. Third, as a practical matter, that someone else has already worked on something means the audience for extensions of those results is at least one (besides oneself) and it is always positive to reach others with one's work. So the productive/constructive response to discovering that one has rediscovered something is to push it farther. This really works in practice. My most recently accepted paper started this way - I worked out something, it seemed so natural that I thought this surely is in the literature already, and, sure enough, there it was, published 5 or 10 years earlier. It was a disappointment, but I kept thinking along the same lines, and it was possible to build on it to obtain something new. Also it brought me into contact with the authors of the previous work, which for me was also positive.
Finally, I would recommend that you get in touch with the mathematics department at the nearest research university. Usually someone is happy to help out an enthusiastic and talented student.