Whether is often a synonym for if, and indeed, if would technically work in this case:
A will react differently if in a different context.
The sentence actually specifies that he will react differently if in a context different from the one he is currently in.
But whether does not work here, because it specifies a choice of two alternatives. For example:
I don't know whether he's home (or not).
Either he's home, or he's not. So I would not recommend using whether.
I have never seen the phrase "according as," but Wiktionary says the following. Notice the whether; I wouldn't use this expression for the same reasons I listed before.
according as (not comparable)
- precisely as; the same as; corresponding to the way in which.
- To the proportion or degree that.
- Depending on whether.
However, "according to" will work, if you remove "differently":
A will react according to the context.
I find the shorter alternative best. It's concise and understandable.
A will react differently depending on the context.
Alternatively, you could wrap it in some fancy words:
A's reaction will be context-sensitive.
[… understand] how a cell can at once assume different shapes whether it is in contact with different surroundings while being able to resist mechanical challenges.
Here whether again is a doubtful word choice. I don't see what this sentence has to do with the shorter alternative. I would personally phrase it as folllows:
[… understand] how a cell can at once assume different shapes depending on the surroundings, while being able to resist mechanical challanges.
If you want to emphasize that the cell must be in contact with the surroundings, this is about as short I can make it:
[… understand] how a cell in contact with different surroundings can at once assume different shapes, while being able to resist mechanical challanges.
Although, that's a tad ambiguous. I'm just spouting out ideas. Anyway: good luck!