If you are using either indexed mode or a background layer then you cannot have transparency on the bottom layer, and erasing will paint the background color instead. If your bottom layer has an underscored name, right click it and pick “Layer from Background”.
Make sure you pick transparent background when you make a new file.