Depending on how many people are connected to the WiFi and how the two routers are set up (both in the way they connect to each other and how their software is set up), and whether the internet is also being shared unknowingly with the public, will depend on the number of IP Addresses that can be assigned.
If you manually changed the IP address your computer has and it didn't work then you could well have tried to use an IP Address that was already taken by somebody else, or alternatively the router has been set up to give you a fixed IP address & what you set up yourself clashed with what the router wanted you to have so you didn't get a connection.
Obtaining an IP Address automatically is the easiest way to get a connection in your situation, because you (presumably) cannot access the configuration page of either Router A or Router B to see what IP Addresses have been assigned to other people.
A little bit more info on IP Addresses: a lot of home routers are only set to give out 150 IP addresses at any one time, with a maximum of 253 IP addresses at any one time (assuming that 192.168.1.0 is the Default Gateway & 192.168.1.255 is always reserved). While I assume that there are not 253 people in your apartment building all using the same Cable Connection (you would need Google Fibre to actually be able to get a half decent connection in that case), it may be possible that people have multiple devices or that the WiFi is not encrypted (i.e. no password required to access it) and as such anyone walking by outside could then use the same internet connection.