You need a wall tile below them to prevent that.
You are using a canopy tile, which is similar to a ceiling tile.
The A3 and A4 tilesets have pairs of tiles, where the bottom of the pair is the vertical part that you can't walk onto, and the top of the pair is the flat part that sits above. Like a tree trunk (vertical) and the leaf canopy (flat); a cliff face (vertical) and grass (flat).
Normally there is always a vertical part below the flat part, which stops you accessing it. But if you provide a way to get onto it, you can access it and walk around on it. Drawing the tiles using the flat part, without the vertical part below it, provides that access.
For your second image, that isn't a wall you've drawn - it's a ceiling. These are also sometimes used as "upper level" tiles if you want to give the appearance of multiple levels in the same map. The actual wall tile is below it in the tileset.
The other thing you can do, if your first image is some kind of tree house that you're looking into from above, is to get a tile from the B-E sheets that has no sprite but the passage is set to X, and draw along the edge of those leaf tiles with it.
This behavior is mostly controlled by the position of the tiles on the sheets.
basically the ability to walk on the ceilings is included intentionally to allow you to simulate a two-level-dungeon on a single level map.
you are supposed to use wall tiles below cailing tiles to prevent climbing up in general, but placing an override (like a ladder tile) on that wall allows you to climb up to the ceiling.
but this override only works from the bottom - if there is a floor tile above or to the side of the ceiling tile, you can't enter or leave the ceiling tile, exactly as if it is on top of the walls themselves with several meters to fall down.