[verb ます-stem] + ようによっては [verb ます-stem] + ようでは [noun] + の + しようによっては
A verb's ます-stem plus よう is a noun meaning "the way of doing it": かんがえよう考えよう is a way of thinking, やりよう a way of going about something. With によっては, it means "depending on how you do it" – done the right way, a different result is possible.
The stem goes before よう, not the dictionary form: ×考えるようによっては. A する verb takes のしよう after its noun: かいしゃく解釈のしようによっては.
によっては means "in some cases", so the second half is a possibility – かもしれない, こともある, a can-do – rather than a certainty.
With では, the same noun points at one particular way, usually with そんな or こんな, and the second half says it will go badly. It is a criticism or a warning.
After the plain form rather than the stem, ようでは is a different pattern: "if it's the case that", as in こんなもんだい問題もできないようでは.
Both are written and formal. In conversation, やりかた方によっては and そんなやりかた方では say the same with ほう方 in place of よう.