When I draw a rectangle, the bounding box covers also the stroke, unlike Illustrator that keeps it on the vector path.
How to deal with this problem? See attachment for a better understanding.
This whole discussion is off-track - let's get back to brass tacks:
You need to draw out, with snapping, multiple rectangles in InDesign which snap such that the strokes all perfectly line up.
IT DOES THAT NOW.
The bounding box at the outer edge of stroke is a non-issue.
Because InDesign automatically snaps also to the inner stroke boundary - exactly for this reason - to align strokes.
So to directly respond to your specific request: I know of no way to alter this behaviour - however, it's not necessary - cos it already works to accomplish your task as-is, out of the box.
Based upon @GerardFalla's answer, Adobe may have improved snapping behavior in more recent versions. I'm still using CS6 most of the time, because I dislike subscription software, and I didn't bother launching CC2017/2018 to test specifically for this answer. This answer is based pretty much on CS6 as I see the behavior.
You can alter the stroke alignment in InDesign via the Stroke Panel.
It appears as though you have the stroke set to align to inside. If you need it centered on the path, like Illustrator, simply click the left-most stroke alignment option in the Stroke Panel.
And you can also enable Smart Guides to align things a bit better if needed.
Edit After the comment:
My understanding is you need 2 rectangles to essentially use the same stroke, centered on their paths respectively. So when overlapped it appears like 1 stroke.
InDesign uses the "preview bounds" for strokes. As far as I'm aware, there's no option to change that like there is in Illustrator. So, you have to compensate for the preview of the strokes.
I don't think you can do this in "1 step", but...
You can alter the stroke alignment on multiple rectangles at the same time without changing other stroke attributes.