This one gets kind Into kind of a gray area. So it sounds like you believed you were in a lateral hazard. Wether you know that was a lateral or not is basically irrelevant. However once you put that new ball into play near where you reasonably felt your ball disappeared into the hazard became your 3rd shot. Now there are rules on properly taking a drop but that's not what this thread is about. This doesn't apply here, but there is a wild hypothetical occurrence where you actually find your ball in the hole. In that very circumstantial situation, the shot that actually went in is your score for the hole, regardless of how many strokes occurred after the one that went in.
Now an actual shot out of bounds or declared lost would require a re-play of the shot. For place of play it is recommended to hit a 'provisional' shot in the event that you are unable to find the original. Of note here is that it has to be declared as a provisional. You literally have to state to the playing partners that you are hitting a provisional ball. Things like 'Im gonna hit another, better hit a backup ball, I'm gonna tee another just in case' don't count. Without actually declaring the shot a provisional you technically made the first ball lost without even looking the moment you put another one into play. I've never personally heard of anyone getting hassled about it during a tournament or meet, but its one of those things that someone can rightfully penalize you for.
For a novice beginner player its important to know there are kind of 2 sets of rules. The actual USGA rules of golf (in the US, elsewhere may use that or the R&A), and local rules. Local rules are special conditions found on the scorecard or otherwise somehow established by the course or event organizers. Usually it involves how to take drops (free or otherwise) in non standard circumstances. For example if you hit into a flower bed or similar beautification. Many times a 'local' rule will give you the right to take free relief in order to keep you from going into it and trying to play out to avoid a penalty. Therefore the course encourages you to just lose your ball instead of doing damage looking for it. And then there's League play. Which is just a giant set of local rules designed for ease and pace of play as its still competition based, but has very few competitive players that fully understand the rules, and some really high handicap players. Out of bounds and lost balls are generally dumbed down to keep scores reasonable and keep people moving.